﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <div>
        <table class="easyui-datagrid" id="RoomTypelist" data-options="rownumbers:true,toolbar:'#TypeRoomtb'">

        </table>
        <div id="TypeRoomtb" style="padding: 2px 5px;">
            <div id="ft" style="padding: 2px 5px;">
                <a href="#" class="easyui-linkbutton" iconcls="icon-add" onclick="addRoomType()" plain="true">添加</a>
            </div>
        </div>
         <div id="roomtypeaddwin" class="easyui-dialog" title="添加" style="width: 490px; height: 520px;"
            data-options="iconCls:'icon-add',resizable:true,modal:true,closed: true">
            <div style="margin: 0 auto; text-align: center;">
                <%using (Html.BeginForm("addTypeRoom", "RoomManage", FormMethod.Post, new { enctype = "multipart/form-data" }))%>
        <%{%>
                <table style="width:69%;">
                    <tr>
                        
                        <td class="auto-style4">房间类型名称：</td>
                        <td class="auto-style3">
                            <input id="roomtypeName" name="roomtypeName" type="text" /></td>
                        
                    </tr>
                  
                  
                      <tr>
                        
                        <td class="auto-style4">房间个数：</td>
                        <td class="auto-style3">
                            <input id="roomnum" name="roomnum" style="height: 96px; width: 209px">
                           </td>
                    </tr>
                    <tr>
                        
                        <td class="auto-style4">床位个数：</td>
                        <td class="auto-style3">
                            <input id="bednum" name="bednum"  style="height: 96px; width: 209px">
                           </td>
                    </tr>
                    <tr>
                        
                        <td class="auto-style4">价格：</td>
                        <td class="auto-style3">
                            <input id="price" name="price"  style="height: 96px; width: 209px">
                           </td>
                    </tr>
                    <tr>
                       
                        <td class="auto-style4">展示图片：</td>
                        <td class="auto-style3">
                            <input id="file" name="file" type="file" accept=".png,.jpg,.gif,.bmp" /></td>
                    </tr>
                </table>
                <input  type="submit" value="添加" />  
                <%} %>

            </div>
        </div> 
    </div>
    <script type="text/javascript">
        $('#RoomTypelist').datagrid({
            url: '../RoomManage/GetRoomTypeList',
            singleSelect: true,
            columns: [[
             { field: 'typename', title: '房间类型', width: 200 },
              { field: 'rooms', title: '房间个数', width: 70 },
              { field: 'bednum', title: '床位数', width: 70 },
              { field: 'Price', title: '价格', width: 70 },
             { field: 'url', title: '图片地址', width: 200 },
                 {
                     field: 'opt', title: '操作', width: 100, align: 'center',
                     formatter: function (value, rec) {
                         var btn = "<a href=" + "#" + " class=" + "easyui-linkbutton" + " iconcls=" + "icon-edit" + " onclick=" + "DelRoomType(" + rec.ID + ")" + " plain=" + "true" + ">删除</a>";
                         return btn;
                     }
                 }
            ]]
        });
        function addRoomType() {
            $('#roomtypeaddwin').dialog('open');
        };
        function DelRoomType(id)
        {
            $.post("../RoomManage/delRoomtype", { ID: id },
               function (data) {
                   if (data == false) {
                       $.messager.alert('未知错误', '删除失败.');
                   }
                   else {
                       $.messager.alert('提示', '删除成功');
                       $('#roomtypeaddwin').datagrid('load', {
                           code: '01',
                           name: 'name'
                       });
                   }
               });
        }
    </script>
</body>
</html>
